package net.asrsmid.config;

/**
 * public class AsApplication<br><br>
 * The class AsApplication represents an Analysis Services application,
 * which corresponds to a <code>&lt;as-application&gt;</code>
 * node and contains all its config data 
 * @author Chen WANG
 * @since 15 June 2011
 */
public class AsApplication {
	private String appId;
	private AsRsAuthMode authMode;
	private String defaultUserName;
	private String defaultUserPassword;
	private String driverName;
	private String serverName;
	private String webserviceExtensionName;
	private String isapiExtensionName;
	private String catalogName;
	private String cubeName;
	private int poolMinIdle;
	private int poolMaxIdle;
	private int poolMaxActive;
	private int poolMaxWait;
	
	/**
	 * Constructs an AsApplication with the given application id 
	 * @param appId
	 */
	public AsApplication(String appId) {
		this.appId = appId;
	}
	
	/**
	 * Returns an olap4j connection string based on the arguments loaded from the config file. 
	 * <br>An olap4j connection has a common form like : <br>
	 * <code>jdbc:xmla:Server=http://server/olap/msmdpump.dll;Catalog=AdventureWorksDW2008R2;
	 * Cube=Adventure Works</code><br>
	 * @param appId as-application id
	 * @return An olap4j connection string
	 */
	public String getOlapConnectionString() {
		StringBuilder sbConnStr = new StringBuilder("jdbc:xmla:");
		sbConnStr.append("Server=http://").append(serverName).append("/");
		sbConnStr.append(webserviceExtensionName).append("/");
		sbConnStr.append(isapiExtensionName);
		sbConnStr.append(";Catalog=").append(catalogName);
		sbConnStr.append(";Cube=").append(cubeName);
		return sbConnStr.toString();
	}
	
	/**
	 * Returns the authentication mode used in this Analysis Services application
	 * @return the authMode
	 */
	public AsRsAuthMode getAuthMode() {
		return authMode;
	}
	/**
	 * Sets the authentication mode used in this Analysis Services application
	 * @param authMode the authMode to set
	 */
	public void setAuthMode(AsRsAuthMode authMode) {
		this.authMode = authMode;
	}
	/** 
	 * Returns the default username used in this Analysis Services application<br>
	 * The default username will be used only in
	 * <code>BASIC</code> or <code>CUSTOMIZED</code>
	 * authentication mode and only when a username is not provided by user
	 * (Eg. user input in GUI) 
	 * @return the defaultUserName
	 */
	public String getDefaultUserName() {
		return defaultUserName;
	}
	/**
	 * Sets the default username used in this Analysis Services application<br>
	 * The default username will be used only in
	 * <code>BASIC</code> or <code>CUSTOMIZED</code>
	 * authentication mode and only when a username is not provided by user
	 * (Eg. user input in GUI) 
	 * @param defaultUserName the defaultUserName to set
	 */
	public void setDefaultUserName(String defaultUserName) {
		this.defaultUserName = defaultUserName;
	}
	/**
	 * Returns the default password used in this Analysis Services application<br>
	 * The default password will be used only in
	 * <code>BASIC</code> or <code>CUSTOMIZED</code>
	 * authentication mode and only when a password is not provided by user
	 * (Eg. user input in GUI) 
	 * @return the defaultUserPassword
	 */
	public String getDefaultUserPassword() {
		return defaultUserPassword;
	}
	/**
	 * Sets the default password used in this Analysis Services application<br>
	 * The default password will be used only in
	 * <code>BASIC</code> or <code>CUSTOMIZED</code>
	 * authentication mode and only when a password is not provided by user
	 * (Eg. user input in GUI) 
	 * @param defaultUserPassword the defaultUserPassword to set
	 */
	public void setDefaultUserPassword(String defaultUserPassword) {
		this.defaultUserPassword = defaultUserPassword;
	}
	/**
	 * Returns the driver used to construct an olap4j connection in this
	 * Analysis Services application
	 * @return the driverName
	 */
	public String getDriverName() {
		return driverName;
	}
	/**
	 * Sets the driver used to construct an olap4j connection in this
	 * Analysis Services application
	 * @param driverName the driverName to set
	 */
	public void setDriverName(String driverName) {
		this.driverName = driverName;
	}
	/**
	 * Returns the server where this Analysis Services application 
	 * is accessible by HTTP
	 * @return the serverName
	 */
	public String getServerName() {
		return serverName;
	}
	/**
	 * Sets the server where this Analysis Services application 
	 * is accessible by HTTP
	 * @param serverName the serverName to set
	 */
	public void setServerName(String serverName) {
		this.serverName = serverName;
	}
	/**
	 * Returns the IIS web service extension of the server where this 
	 * Analysis Services application is accessible by HTTP
	 * @return the webserviceExtensionName
	 */
	public String getWebserviceExtensionName() {
		return webserviceExtensionName;
	}
	/**
	 * Sets the IIS web service extension of the server where this 
	 * Analysis Services application is accessible by HTTP
	 * @param webserviceExtensionName the webserviceExtensionName to set
	 */
	public void setWebserviceExtensionName(String webserviceExtensionName) {
		this.webserviceExtensionName = webserviceExtensionName;
	}
	/**
	 * Returns the IIS ISAPI extension of the server where this
	 * Analysis Services application is accessible by HTTP
	 * @return the isapiExtensionName
	 */
	public String getIsapiExtensionName() {
		return isapiExtensionName;
	}
	/**
	 * Sets the IIS ISAPI extension of the server where this
	 * Analysis Services application is accessible by HTTP
	 * @param isapiExtensionName the isapiExtensionName to set
	 */
	public void setIsapiExtensionName(String isapiExtensionName) {
		this.isapiExtensionName = isapiExtensionName;
	}
	/**
	 * Returns the catalog where exists the cubes to visit in 
	 * this Analysis Services application
	 * @return the catalogName
	 */
	public String getCatalogName() {
		return catalogName;
	}
	/**
	 * Sets the catalog where exists the cubes to visit in 
	 * this Analysis Services application
	 * @param catalogName the catalogName to set
	 */
	public void setCatalogName(String catalogName) {
		this.catalogName = catalogName;
	}
	/**
	 * Returns the initial cube to visit in this Analysis Services application
	 * @return the cubeName
	 */
	public String getCubeName() {
		return cubeName;
	}
	/**
	 * Sets the initial cube to visit in this Analysis Services application
	 * @param cubeName the cubeName to set
	 */
	public void setCubeName(String cubeName) {
		this.cubeName = cubeName;
	}
	/**
	 * Returns minimum idle connection number of the olap4j connection pool
	 * used in this Analysis Services application
	 * @return the poolMinIdle
	 */
	public int getPoolMinIdle() {
		return poolMinIdle;
	}
	/**
	 * Sets minimum idle connection number of the olap4j connection pool
	 * used in this Analysis Services application
	 * @param poolMinIdle the poolMinIdle to set
	 */
	public void setPoolMinIdle(int poolMinIdle) {
		this.poolMinIdle = poolMinIdle;
	}
	/**
	 * Returns maximum idle connection number of the olap4j connection pool
	 * used in this Analysis Services application
	 * @return the poolMaxIdle
	 */
	public int getPoolMaxIdle() {
		return poolMaxIdle;
	}
	/**
	 * Sets maximum idle connection number of the olap4j connection pool
	 * used in this Analysis Services application
	 * @param poolMaxIdle the poolMaxIdle to set
	 */
	public void setPoolMaxIdle(int poolMaxIdle) {
		this.poolMaxIdle = poolMaxIdle;
	}
	/**
	 * Returns maximum active connection number of the olap4j connection pool
	 * used in this Analysis Services application
	 * used in this Analysis Services application
	 * @return the poolMaxActive
	 */
	public int getPoolMaxActive() {
		return poolMaxActive;
	}
	/**
	 * Sets maximum active connection number of the olap4j connection pool
	 * used in this Analysis Services application
	 * @param poolMaxActive the poolMaxActive to set
	 */
	public void setPoolMaxActive(int poolMaxActive) {
		this.poolMaxActive = poolMaxActive;
	}
	/**
	 * Returns maximum wait time to obtain a connection from the olap4j 
	 * connection pool used in this Analysis Services application
	 * @return the poolMaxWait
	 */
	public int getPoolMaxWait() {
		return poolMaxWait;
	}
	/**
	 * Sets maximum wait time to obtain a connection from the olap4j 
	 * connection pool used in this Analysis Services application
	 * @param poolMaxWait the poolMaxWait to set
	 */
	public void setPoolMaxWait(int poolMaxWait) {
		this.poolMaxWait = poolMaxWait;
	}
	/**
	 * Returns the application id of this Analysis Services application
	 * @return the appId
	 */
	public String getAppId() {
		return appId;
	}
	/**
	 * Sets the application id of this Analysis Services application
	 * @param appId the appId to set
	 */
	public void setAppId(String appId) {
		this.appId = appId;
	}
}